package com.example.demo.controller.AuthorControl;

import com.example.demo.entity.BackResponseEntity;
import com.example.demo.entity.requestJson.*;
import com.example.demo.entity.responseJson.ListResult;
import com.example.demo.entity.responseJson.OnelevelCommentRes;
import com.example.demo.entity.responseJson.TwoLevelCommentRes;
import com.example.demo.service.BookCommentService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author : 洪俊新
 * @date : 2021/3/11 15:22
 * @description:
 */
@RestController
@RequestMapping("/author/bookcomment")
@Api(value = "书籍评论接口", tags = "书籍评论接口")
public class BookCommentController {
    @Autowired
    private BookCommentService bookCommentService;

    @ApiOperation(value = "用户发表一级评论", notes = "在章节后评论需要传chapterId和chapterName")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )
    @PostMapping("/putonelevelcomment")
    public BackResponseEntity<Object> putOneLevelComment(@RequestBody PutOneLevelCommentReq putOneLevelCommentReq){
        return bookCommentService.putOneLevelComment(putOneLevelCommentReq);
    }

    @ApiOperation(value = "查询书籍或章节一级评论", notes = "查询章节后评论需要传chapterId和bookId")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )
    @GetMapping("/queryonelevelcomment")
    public BackResponseEntity<ListResult<List<OnelevelCommentRes>>> queryOneComment(QueryBookCommentReq bookCommentReq){
        return bookCommentService.queryOneComment(bookCommentReq);
    }

    @ApiOperation(value = "用户回复一级评论", notes = "")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )
    @PostMapping("/puttwolevelcomment")
    public BackResponseEntity<Object> putTwoLevelComment(@RequestBody PutBookTwoCommentReq putBookTwoCommentReq){
        return bookCommentService.putTwoLevelComment(putBookTwoCommentReq);
    }

    @ApiOperation(value = "查询二级评论", notes = "传parentCommentId")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )
    @GetMapping("/querytwolevelcomment")

    public BackResponseEntity<ListResult<List<TwoLevelCommentRes>>> queryTwoeComment(DeleteReq deleteReq){
        return bookCommentService.queryTwoeComment(deleteReq);
    }

    @ApiOperation(value = "用户回复二级评论", notes = "")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )
    @PostMapping("/replytwolevelcomment")

    public BackResponseEntity<Object> replyTwoComment(@RequestBody ReplyTwoCommentReq replyTwoCommentReq){
        return bookCommentService.replyTwoComment(replyTwoCommentReq);
    }

    @ApiOperation(value = "查询我的评论", notes = "传userId")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )
    @GetMapping("/querymycomment")
    public BackResponseEntity<List<TwoLevelCommentRes>> querymyComment(DeleteReq deleteReq){
        return bookCommentService.querymyComment(deleteReq);
    }

    @ApiOperation(value = "查询评论我的", notes = "传userId")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )
    @GetMapping("/queryreplymycomment")
    public BackResponseEntity<List<TwoLevelCommentRes>> queryreplymyComment(DeleteReq deleteReq){
        return bookCommentService.queryreplymyComment(deleteReq);
    }

    @ApiOperation(value = "用户删除评论", notes = "传userId")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )
    @GetMapping("/deletemycomment")

    public BackResponseEntity<Object> deleteComments(DeleteCommmentReq deleteCommmentReq){
        return bookCommentService.deleteComments(deleteCommmentReq);
    }
}
